package com.lagou.dao;

import com.lagou.bean.Student;
import com.lagou.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class StudentViewDaoImp implements StudentViewDao{
    @Override
    /**
     * 自定义抽象方法实现查找所有学生操作
     * @return
     */
    public List<Student> StudentView() {
        QueryRunner qr = new QueryRunner(DruidUtils.getDataSource());
        String sql = "select * from t_student";
        List<Student> students = null;
        try {
            students = qr.query(sql, new BeanListHandler<Student>(Student.class));
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return students;
    }
}
